# -*- codeing = utf-8 -*-
# @Time : 2024/3/20 16:21
# @Author : huangjing
# @File : myIterator.py
# @Software : PyCharm
class MyIterator:
    def __init__(self,start,end):
        self.current = start
        self.end = end

    def __iter__(self):
        return self

    def __next__(self):
        if self.current < self.end:
            self.current += 1
            return self.current - 1
        else:
            raise StopIteration
def my_generator(start,end):
    current = start
    while current < end:
        yield current
        current += 1
def my_generator01():
    n = (x ** 2 for x in range(10))
    print(type(n))
    for i in n:
        print(i,end=' ')
if __name__ == '__main__':
    n = MyIterator(0,10)
    for i in n:
        print(i,end=" ")
    print("")
    a = my_generator(0,10)
    for i in a:
        print(i,end=" ")
    my_generator01()